#!/bin/bash
OK=0
WARN=1
CRITICAL=2
UNKNOWN=3
PATH="/bin:/sbin:/usr/bin:/usr/sbin"

Ok_name=''
Fail_name=''
Warn_name=''
Judge_W=0
Judge_C=0
PWDP=$(cd "$(dirname "$0")"; pwd)
DiskmonitorP=$PWDP/diskmonitor
c_host=`hostname -s`

for i in `grep $c_host $DiskmonitorP| awk -F ';' '{print $2}'`
do
        $PWDP/check_disk -c 0.5% -w 5% -p $i > /dev/null
        Temp=$?
        if (( $Temp == 1))
        then 
                Judge_W=1
                Warn_name="${Warn_name} ${i}"
        elif (( $Temp == 2 ))
        then
                Judge_C=1
                Fail_name="${Fail_name} ${i}"
        fi

done

if [ $Judge_C -eq 1 ]
then
        echo "$Fail_name  wrong"
        exit $CRITICAL
elif [ $Judge_W -eq 1 ]
then
        echo "$Warn_name  warnning"
        exit $WARN
else
        echo " all disk space are OK "
        exit $OK
fi
